<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('选择课程')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-stuCourse-add" th:object="${course}">
        <input name="courseId" th:field="*{id}"  type="hidden">

        <div class="form-group">
            <label class="col-sm-3 control-label  is-required">课程名称：</label>
            <div class="col-sm-8">
                <input name="courseName" class="form-control" th:field="*{title}" type="text" readonly>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">图片：</label>
            <div class="col-sm-8">
                <div class="layui-upload">
                    <div class="layui-upload-list">
                        <img class="layui-upload-img" id="demo1" th:src="*{image}" style="width: 95px;height: 95px">
                        <p id="demoText"></p>
                    </div>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">教师：</label>
            <div class="col-sm-8">
                <input  class="form-control" th:field="*{userName}" type="text" readonly>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >年级：</label>
            <div class="col-sm-8">
                <input  class="form-control" th:field="*{grade}" type="text" readonly>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">介绍：</label>
            <div class="col-sm-8">
                <textarea  rows="5"  class="form-control" readonly>[[*{introduce}]]</textarea>
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var prefix = ctx + "edu/stuCourse"
    $("#form-stuCourse-add").validate({
        focusCleanup: true
    });
    var flag = [[${flag}]];

    var course = [[${course}]];
    function submitHandler() {
        if(flag==1){
            $.modal.msgError("您已经选择次课程，不能重复选择");
            return
        }
        if ($.validate.form()) {
            var data = [];
            data.push({"name": "status", "value": "0"});
            data.push({"name": "courseId", "value":course.id});
            data.push({"name": "courseName", "value": course.title});
            $.operate.save(prefix + "/add", data);
        }
    }

</script>
</body>
</html>
